package tgc.edu.yzy.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import tgc.edu.yzy.entity.Teacher;

public class TeacherInterceptor extends HandlerInterceptorAdapter{
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		Teacher teacher=(Teacher) request.getSession().getAttribute("teachers");
		if(teacher==null) {
			System.out.println("有非法人员访问");
			response.sendRedirect(request.getContextPath()+"/homepage/index");
			return false;
		}
		return super.preHandle(request, response, handler);
	}
	
}
